package com.appspot.yusupova;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.appspot.yusupova.verses.CachedVerseMap;

/**
 * This servlet is usin 
 * 
 * @author Rouslan Shchoutchinov
 */
@SuppressWarnings("serial")
public final class SearchVerseServlet extends HttpServlet {

    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        String searchPhrase = req.getParameter("phrase");
        String text = CachedVerseMap.get(searchPhrase);
        PrintWriter writer = resp.getWriter();
        try {
            if (text != null) {
                writer.println(text);
            } else {
                writer.println("Not found");
            }
        } finally {
            writer.close();
        }
    }
    
}
